import 'package:flutter/material.dart';

/// Container
class ContainerRoute extends StatefulWidget {
  @override
  _ContainerRouteState createState() => _ContainerRouteState();
}

class _ContainerRouteState extends State<ContainerRoute> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text("Container"),
      ),
      body: _ContainerRouteBody(),
    );
  }
}

class _ContainerRouteBody extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Column(
      children: <Widget>[
        Container(
          margin: EdgeInsets.only(top: 50.0, left: 120.0),
          constraints: BoxConstraints.tightFor(width: 200.0, height: 150.0),
          //卡片大小
          decoration: BoxDecoration(
            // 背景装饰
            gradient: RadialGradient(
                //径向渐变
                colors: [Colors.red, Colors.orange],
                center: Alignment.topLeft,
                radius: .98),
            boxShadow: [
              //阴影
              BoxShadow(
                  color: Colors.black54,
                  offset: Offset(2.0, 2.0),
                  blurRadius: 4.0)
            ],
          ),
          // 切斜变换
          transform: Matrix4.rotationZ(.2),
          alignment: Alignment.center,
          child: Text(
            "5.20",
            style: TextStyle(color: Colors.white, fontSize: 40.0),
          ),
        ),
        SizedBox(
          height: 50.0,
        ),
        Container(
          margin: EdgeInsets.all(20.0),
          color: Colors.orange,
          child: Text("hello world"),
        ),
        Container(
          padding: EdgeInsets.all(20.0),
          color: Colors.orange,
          child: Text("hello world"),
        ),
        SizedBox(
          height: 20.0,
        ),
        Text("通过padding实现Container"),
        Padding(
          padding: EdgeInsets.all(20.0),
          child: DecoratedBox(
            decoration: BoxDecoration(color: Colors.orange),
            child: Text("Hello world"),
          ),
        ),
        DecoratedBox(
          decoration: BoxDecoration(color: Colors.orange),
          child: Padding(
            padding: const EdgeInsets.all(20.0),
            child: Text("Hello World"),
          ),
        ),
      ],
    );
  }
}
